package com.stone.javassist;


import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import javassist.*;
import javassist.CtField.Initializer;

/**
 * @author Stony
 * Created Date : 2016/4/27  9:57
 */
public class Js {
    public static void main(String[] args) throws Exception{
        ClassPool cp = ClassPool.getDefault();
        CtClass javaUtils = cp.get("com.seventh7.mybatis.util.JavaUtils");

        //System.out.println("cc == " + cc);


        CtMethod refValid =  javaUtils.getDeclaredMethod("refValid");
        System.out.println("method == " + refValid);
        refValid.setBody("{validated = true; valid = true; return valid;}");
        javaUtils.writeFile("ok\\class");


        CtClass javaService = cp.get("com.seventh7.mybatis.service.JavaService");
        CtMethod stop = javaService.getDeclaredMethod("stop");
        stop.setBody("{return;}");
        javaService.writeFile("ok\\class");


    }
}
